<html>
<head></head>
<body>

<script type="text/javascript" src="socket.io.min.js"></script>
<script>
	var socket = io.connect('http://chat:3001'),
		messageBox = document.querySelector('#textMessage'),
		displayMessage = document.querySelector('#wrapChat');

	socket.on('c_receive', function (data) {
		console.log(data);
		displayMessage.innerHTML += data.message+'<br>';
	})
	.on('error', function (data) {
	console.log(data);
	});

	messageBox.onkeydown = function(e){
		e = e || window.event;
		var charCode = e.keyCode || e.which;
	    if (charCode == 13) {
	        // alert("Enter");
	        socket.emit('s_receive', { message : messageBox.value, time : new Date().getTime(), targetId : 131118234353901600});
	        messageBox.value = '';
	    }
	}
</script>
</body>
</html>